<?php

class Main extends Controller 
{

	function Main()
	{
		parent::Controller();
		//$this->load->library('css');		
		$this->load->library('flickr');
		$this->load->library('simplepie');
		$this->load->helper('html');
		$this->load->helper('url');
		$this->load->helper('mypage'); //zeratool helper.
	}
	
	function index()
	{
		$url = "http://api.flickr.com/services/feeds/photos_public.gne?id=22525955@N05&lang=en-us&format=rss_200";
		//$this->css->addlink('style');
		$data['title'] = "Home";
		$data["welcomemsg"] = "<p><strong>Welcome to badjography!</strong></p><br /> Here you will see
		                        my photography and web development works. Thanks!";
        $data["photos"] = $this->getMainImg("medium");
        $data["latestexhibits"] = $this->getMainImg("small");
        $data["description"] = $this->getTagcontent();
        $this->load->view('main_body', $data);
	}
	
	function getMainImg($imgsize){
		/*
		 * $imgsize: square, small, thumbnail, medium, large
		 */
		
		$config = array(
			'type'				=> 'user',
			'user'				=> '22525955@N05',
			'num_items'		    => 1,
			'rss_cache_path'	=> APPPATH.'cache/flickr-rss-cache',
			'cache_time'		=> 3600,
			'img_cache_path'	=> APPPATH.'cache/flickr-image-cache',
			'img_cache_url'		=> $this->config->item('base_url').'application/cache/flickr-image-cache',
			'use_cache'			=> false,
			'image_size'		=> $imgsize,
			'tags'				=> ''
		);
 
		$this->flickr->init($config);
 
		return $this->flickr->get_photos();
	}
	
	function getTagcontent()
	{
		$this->simplepie->set_feed_url('http://api.flickr.com/services/feeds/photos_public.gne?id=22525955@N05');
		$this->simplepie->set_cache_location(APPPATH.'cache/rss');
		$this->simplepie->init();
		$this->simplepie->handle_content_type();
 
		return $this->simplepie->get_items();
	}
}

/* End of file main.php */
/* Location: ./system/application/badjography/controllers/main.php */
